package net.blank.world.world2D.business.unit
{
	import net.blank.functionUtl.FunctionBinder;
	import net.blank.world.world2D.template.unit.MovableObject_tmp;

	/**
	 * 动物
	 * @author blank
	 * 
	 */
	public class MovableObject extends Inorganic
	{
		/**
		 * 增加的速度
		 */
		protected var _addSpeed:int;
		
		/**
		 * <font color=#0000ff>[可绑定]</font>增加的速度
		 * @param value
		 * 
		 */
		public function setAddSpeed(value:int):void{
			if(value != _addSpeed){
				_addSpeed=value;
				
				FunctionBinder.execCallbackFun(setAddSpeed,[this]);
			}
		}
		
		/**
		 * 增加的速度
		 * @return 
		 * 
		 */
		public function getAddSpeed():int{
			return _addSpeed;
		}
		
		/**
		 * 速度
		 * @return 
		 * 
		 */
		public function getSpeed():int{
			return (getTemplate() as MovableObject_tmp).baseSpeed+_addSpeed;
		}
		
		/**
		 * 方向
		 */
		protected var _direction:int;
		
		/**
		 * <font color=#0000ff>[可绑定]</font>方向
		 * @param value
		 * 
		 */
		public function setDirection(value:int):void{
			if(value != _direction){
				_direction=value;
				
				FunctionBinder.execCallbackFun(setDirection,[this]);
			}
		}
		
		/**
		 * 方向
		 * @return 
		 * 
		 */
		public function getDirection():int{
			return _direction;
		}
		
		/**
		 * 动物
		 * @param template
		 * 
		 */
		public function MovableObject(template:MovableObject_tmp)
		{
			super(template);
		}
		
		override public function reset():void{
			super.reset();
			
			FunctionBinder.clearBindingFuns(setAddSpeed,setDirection);
			
			_addSpeed=0;
			_direction=0;
		}
		
		override public function destroy():void{
			super.destroy();
			
			FunctionBinder.clearBindingFuns(setAddSpeed,setDirection);
		}
		
		override protected function copyProperties(obj:AbstractUnit):void{
			super.copyProperties(obj);
			
			var t:MovableObject=obj as MovableObject;
			
			t._addSpeed=_addSpeed;
			t._direction=_direction;
		}
		
		override public function clone():*{
			var obj:MovableObject=new MovableObject(getTemplate() as MovableObject_tmp);
			
			copyProperties(obj);
			
			return obj;
		}
	}
}